﻿@model tb_article
@{
    ViewBag.Title = (Model.Id > 0 ? "修改" : "添加") + "新闻";
    Layout = "~/Areas/Admin/Views/Shared/_RightLayout.cshtml";
    string topClassUrlCode = CacheHelper<tb_topclass>.GetById(Model.TopClassId).UrlCode;
    string subClassUrlCode = CacheHelper<tb_subclass>.GetById(Model.ClassId).UrlCode;
}
<script src="@Url.Content("~/scripts/ckeditor/ckeditor.js")" type="text/javascript"></script>
<script src="@Url.Content("~/scripts/ckfinder/ckfinder.js")" type="text/javascript"></script>
<script type="text/javascript">
    function BrowseServer(inputId) {
        var finder = new CKFinder();
        finder.basePath = '/scripts/ckfinder/';
        finder.selectActionFunction = SetFileField;
        finder.selectActionData = inputId;
        finder.startupPath = 'Images:images';
        finder.resourceType = 'Images';
        finder.popup();
    }
    function SetFileField(fileUrl, data) {
        document.getElementById(data["selectActionData"]).value = fileUrl;
    } 

    var topClassUrlCode = '@topClassUrlCode';
    var subClassUrlCode = '@subClassUrlCode';
    var urlCode = '@Model.UrlCode';
    function selParentClass() {
//        var pitem = $("#parentclass");
//        var pid = pitem.val();
//        if (pid) {
//            $("span option[rev]").unwrap();
//            $("option[rev]").wrap("<span style='display:none'></span>");
//            $("option[rev=" + pid + "]").unwrap();
//        }
        subClassUrlCode = $("#parentclass").find("option:selected").attr("UrlCode");
        resetUrlCode();
    }
    function selTopClass() {
        var pitem = $("#topclass");
        var pid = pitem.val();
        if (pid) {
            $("#parentclass").find("option").hide();
            $("#parentclass").find("option[trev=" + pid + "]").show();
            $("#parentclass").val($("#parentclass option[trev=" + pid + "]:first").val());
            selParentClass();
        }        
        topClassUrlCode = $("#topclass").find("option:selected").attr("UrlCode");
        resetUrlCode();
    }

    function resetUrlCode()
    {
        $("#urlString").text(topClassUrlCode + "/" + subClassUrlCode +"/"+urlCode);
    }

    $(document).ready(function () {

        var pitem = $("#topclass");
        var pid = pitem.val();
        if (pid) {
            $("#parentclass").find("option").hide();
            $("#parentclass").find("option[trev=" + pid + "]").show();
            if (!subClassUrlCode)
                $("#parentclass").val($("#parentclass option[trev=" + pid + "]:first").val());
        }
        if (!subClassUrlCode)
            subClassUrlCode = $("#parentclass").find("option:selected").attr("UrlCode");
        if (!topClassUrlCode)
            topClassUrlCode = $("#topclass").find("option:selected").attr("UrlCode");

        $("#UrlCode").change(function () {
            urlCode = this.value;
            resetUrlCode();
        });
        resetUrlCode();
        // $("#parentclass").val("@Model.ClassId");

    });
</script>
<form id="editForm" name="editForm" method="post" action="/Admin/Article/Save/@if (Model.Id > 0) { Write(Model.Id.ToString()); }">
<div id="panelBar">
    <ul class="toolBar">
        <li>
            <input class="submit" type="submit" value="保存" /></li>
        <li><a class="back" href="javascript:void(0)"><span>返回</span></a></li>
    </ul>
</div>
<div id="edit">
   @* <script language="javascript" type="text/javascript">
        function secBoard(n) {
            for (i = 0; i < secTable.cells.length; i++)
                secTable.cells[i].className = "sec1";
            secTable.cells[n].className = "sec2";
            for (i = 0; i < mainTable.tBodies.length; i++)
                mainTable.tBodies[i].style.display = "none";
            mainTable.tBodies[n].style.display = "block";
        }
    </script>*@
    <!--HTML部分-->
    @if (!ViewBag.IsNews)
    {
    <div>
        设置Url：
        <select id="topclass" name="topclassid" onchange="selTopClass();">
            @foreach (tb_topclass topClass in CacheHelper<tb_topclass>.GetAll())
            {
            <option UrlCode="@topClass.UrlCode" value="@topClass.Id" @(Model.TopClassId == topClass.Id ? "selected" : "")>@topClass.Name_Zh_cn</option>
            }
        </select>
        <select id="parentclass" name="subclass" onchange="selParentClass();">
            @foreach (tb_subclass subClass in ViewBag.SubClass)
            {
            <option UrlCode="@subClass.UrlCode" value="@subClass.Id" trev="@subClass.TopClassId" @(Model.ClassId == subClass.Id ? "selected" : "")>@subClass.Name_Zh_cn</option>
            }
        </select>
        UrlCode: <input type="text" name="UrlCode" id="UrlCode" value="@Model.UrlCode" />
        <span id="urlString"></span>
        @*
        <span style="display:@(ViewBag.IsNews?"none":"")">&nbsp;&nbsp;</span>
        <select id="subclass" name="subclass">
            @foreach (tb_subclass item in (List<tb_subclass>)ViewData["subclass"])
            {
                <option value="@item.Id" rev="@item.parentid">@item.Name_Zh_cn</option>
            }
        </select>*@
        <br />

    </div>
    }
    else
    {
    <div>
        选择分类：
        <select id="subclass" name="subclass">
            @foreach (tb_subclass item in ViewBag.SubClass)
            {
                <option value="@item.Id" @(Model.ClassId==item.Id ? "selected":"")>@item.Name_Zh_cn</option>
            }
        </select>
        <br />
    </div>
    }
    <input type="hidden" name="isnews" value="@ViewBag.IsNews" />
    @*<table width="72%" border="0" cellpadding="0" cellspacing="0" id="secTable">
        <tbody>
            <tr align="middle" height="20">
                <td align="center" class="sec2" onclick="secBoard(0)">
                    简体中文
                </td>
                <td align="center" class="sec1" onclick="secBoard(1)">
                    繁体中文
                </td>
                <td align="center" class="sec1" onclick="secBoard(2)">
                    &nbsp;&nbsp;英&nbsp;&nbsp;文&nbsp;&nbsp;
                </td>
            </tr>
        </tbody>
    </table>*@
    <table class="main_tab" id="mainTable" cellspacing="0" cellpadding="0" width="100%"
        border="0">
        <!--简体中文-->
        <tbody style="display: block">
            <tr>
                <td valign="top" align="middle">
                    <table width="98%" height="133" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td height="5" colspan="3">
                                </td>
                            </tr>
                            <tr>
                                <td width="4%" height="28" background="/images/news-title-bg.gif">
                                </td>
                                <td height="25" colspan="2" background="/images/news-title-bg.gif" class="left_txt">
                                    <font color="#FFFFFF" class="left_ts" /><b></b>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">标&nbsp;&nbsp;题： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="Title_Zh_cn" style= "width:70%;" name="Title_Zh_cn" type="text" value="@Model.Title_Zh_cn" required="required" title="请输入" />
                                    </span>
                                    &nbsp;&nbsp;标题建议不要超过22个字。
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">内&nbsp;&nbsp;容： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <textarea id="Content_Zh_cn" name="Content_Zh_cn" alt="请输入Content_Zh_cn" >@Model.Content_Zh_cn</textarea>
                                        <script type="text/javascript">
                                            CKEDITOR.replace('Content_Zh_cn',
                                                        {
                                                            toolbar:
        [
           ['Source', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
    ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
    ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
    ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
    '/',
    ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
    ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
    ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
    ['Link', 'Unlink', 'Anchor'],
    ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
    '/',
    ['Styles', 'Format', 'Font', 'FontSize'],
    ['TextColor', 'BGColor'],
    ['Maximize', 'ShowBlocks', '-', 'About']

        ],
                                                            skin: 'office2003',
                                                            height: 400,
                                                            scayt_autoStartup: false,
                                                            filebrowserBrowseUrl: '/scripts/ckfinder/ckfinder.html',
                                                            filebrowserImageBrowseUrl: '/scripts/ckfinder/ckfinder.html?Type=Images',
                                                            filebrowserFlashBrowseUrl: '/scripts/ckfinder/ckfinder.html?Type=Flash',
                                                            filebrowserUploadUrl: '/scripts/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                                                            filebrowserImageUploadUrl: '/scripts/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                                                            filebrowserFlashUploadUrl: '/scripts/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
                                                        });
                                        </script>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">Tag： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="KeyWord_Zh_cn" style= "width:40%;" name="KeyWord_Zh_cn" type="text" value="@Model.KeyWord_Zh_cn" title="请输入" />
                                    </span>
                                </td>
                            </tr>
                            @if (!ViewBag.IsNews)
                            {
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">排序： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="Order" style= "width:40%;" name="Order" type="text" value="@Model.Order" title="请输入顺序" />
                                    </span>
                                </td>
                            </tr>
                            }
                            <tr>
                                <td height="5" colspan="3">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
        <!--繁体中文-->@*
        <tbody style="display: none">
            <tr>
                <td valign="top" align="middle">
                    <table width="98%" height="133" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td height="5" colspan="3">
                                </td>
                            </tr>
                            <tr>
                                <td width="4%" height="28" background="/images/news-title-bg.gif">
                                </td>
                                <td height="25" colspan="2" background="/images/news-title-bg.gif" class="left_txt">
                                    <font color="#FFFFFF" class="left_ts" /><b></b>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">標&nbsp;&nbsp;題： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="Title_Zh_tw" style= "width:70%;" name="Title_Zh_tw" type="text" value="@Model.Title_Zh_tw" required="required" title="請輸入" />
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">内&nbsp;&nbsp;容： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <textarea id="Content_Zh_tw" name="Content_Zh_tw" alt="請輸入Content_Zh_cn" required="required">@Model.Content_Zh_tw</textarea>
                                        <script type="text/javascript">
                                            CKEDITOR.replace('Content_Zh_tw',
                                                        {
                                                            toolbar:
        [
           ['Source', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
    ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
    ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
    ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
    '/',
    ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
    ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
    ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
    ['Link', 'Unlink', 'Anchor'],
    ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
    '/',
    ['Styles', 'Format', 'Font', 'FontSize'],
    ['TextColor', 'BGColor'],
    ['Maximize', 'ShowBlocks', '-', 'About']

        ],
                                                            skin: 'office2003',
                                                            height: 400,
                                                            scayt_autoStartup: false
                                                        });
                                        </script>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">Tag： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="KeyWord_Zh_tw" style= "width:40%;" name="KeyWord_Zh_tw" type="text" value="@Model.KeyWord_Zh_tw" title="請輸入" />
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td height="5" colspan="3">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>*@
        <!--英文-->@*
        <tbody style="display: none">
            <tr>
                <td valign="top" align="middle">
                    <table width="98%" height="133" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td height="5" colspan="3">
                                </td>
                            </tr>
                            <tr>
                                <td width="4%" height="28" background="/images/news-title-bg.gif">
                                </td>
                                <td height="25" colspan="2" background="/images/news-title-bg.gif" class="left_txt">
                                    <font color="#FFFFFF" class="left_ts" /><b></b>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">&nbsp;Title&nbsp;： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="Title_En_us" style= "width:70%;" name="Title_En_us" type="text" value="@Model.Title_En_us" required="required" title="Please enter" />
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">&nbsp;Content&nbsp;： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <textarea id="Content_En_us" name="Content_En_us" alt="Please enter Content_En_us"
                                            required="required">@Model.Content_En_us</textarea>
                                        <script type="text/javascript">
                                            CKEDITOR.replace('Content_En_us',
                                                        {
                                                            toolbar:
        [
           ['Source', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
    ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
    ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
    ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
    '/',
    ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
    ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
    ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
    ['Link', 'Unlink', 'Anchor'],
    ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
    '/',
    ['Styles', 'Format', 'Font', 'FontSize'],
    ['TextColor', 'BGColor'],
    ['Maximize', 'ShowBlocks', '-', 'About']

        ],
                                                            skin: 'office2003',
                                                            height: 400,
                                                            scayt_autoStartup: false
                                                        });
                                        </script>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FAFBFC">
                                    &nbsp;
                                </td>
                                <td width="10%" height="25" bgcolor="#FAFBFC">
                                    <span class="left_txt">Tag： </span><span class="left_ts"></span>
                                </td>
                                <td width="86%" height="25" bgcolor="#FAFBFC" style="text-align: left;">
                                    <span class="required left_txt">
                                        <input id="KeyWord_En_us" style= "width:40%;" name="KeyWord_En_us" type="text" value="@Model.KeyWord_En_us" title="Please enter" />
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td height="5" colspan="3">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>*@
    </table>
    <ul>
    @if (ViewBag.IsNews)
    {
        <li><span class="label">是否放在首页：</span>显示在首页的相关栏目 <span>
            <input type="checkbox" id="IsHot" name="IsHot" value="true" @Html.Raw(Model.IsHot ? "checked='checked'" : "") />
        </span></li>
        <li><span class="label">图片地址：</span>显示在首页左边的重要新闻  <span>
            <script type="text/javascript">
                function BrowseServer(inputId) {
                    var finder = new CKFinder();
                    finder.basePath = '/scripts/ckfinder/';
                    finder.selectActionFunction = SetFileField;
                    finder.selectActionData = inputId;
                    finder.startupPath = 'Images:images';
                    finder.resourceType = 'Images';
                    finder.popup();
                }
                function SetFileField(fileUrl, data) {
                    document.getElementById(data["selectActionData"]).value = fileUrl;
                } 
            </script>
            <input id="PicUrl" name="PicUrl" type="text" value="@Model.PicUrl"  title="请输入" />
            <input type="button" value=" 浏 览 " onclick="BrowseServer('PicUrl');" />
        </span></li>
    }
    else
    {
        
        <li style="display:@(ViewBag.IsNews ? "none" : "")"> 
			<span class="label">简体中文简介：</span>
            <span class="required">
                <input id="summary_zh_cn" style="width:600px;" name="summary_zh_cn" type="text" value="@Model.summary_zh_cn" title="请输入" /> 
            </span>
		</li>
        <li style="display:@(ViewBag.IsNews ? "none" : "")"> 
			<span class="label">繁体中文简介：</span>
            <span class="required">
                <input id="summary_zh_tw" style="width:600px;" name="summary_zh_tw" type="text" value="@Model.summary_zh_tw" title="请输入" /> 
            </span>
		</li>
        <li style="display:@(ViewBag.IsNews ? "none" : "")"> 
			<span class="label">英文简介：</span>
            <span class="required">
                <input id="summary_en_us" style="width:600px;" name="summary_en_us" type="text" value="@Model.summary_en_us" title="请输入" /> 
            </span>
		</li>
        <li> 
			<span class="label">图片地址(简体中文)：</span>
            <span >
                <input id="PicUrl_Zh_cn" name="PicUrl_Zh_cn" type="text" value="@Model.PicUrl_Zh_cn"  title="请输入" /> 
                <input type="button" value=" 浏 览 " onclick="BrowseServer('PicUrl_Zh_cn');" />
            </span>
		</li> 
        <li> 
			<span class="label">图片地址(繁体中文)：</span>
            <span >
                <input id="PicUrl_Zh_tw" name="PicUrl_Zh_tw" type="text" value="@Model.PicUrl_Zh_tw"  title="请输入" /> 
                <input type="button" value=" 浏 览 " onclick="BrowseServer('PicUrl_Zh_tw');" />
            </span>
		</li> 
        <li> 
			<span class="label">图片地址(英文)：</span>
            <span >
                <input id="PicUrl_En_us" name="PicUrl_En_us" type="text" value="@Model.PicUrl_En_us"  title="请输入" /> 
                <input type="button" value=" 浏 览 " onclick="BrowseServer('PicUrl_En_us');" />
            </span>
		</li> 
    }
    </ul>
</div>
</form>
